package dao.pojo;

import java.sql.Timestamp;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * Order entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "order", catalog = "onlinemall")
public class Order implements java.io.Serializable {

	// Fields

	private Integer orderId;
	private ReceivingAddress receivingAddress;
	private Short state;
	private Timestamp orderTime;
	private Timestamp payTime;
	private Timestamp confirmTime;
	private Set<OrderCommodityInfo> orderCommodityInfos = new HashSet<OrderCommodityInfo>(
			0);

	// Constructors

	/** default constructor */
	public Order() {
	}

	/** minimal constructor */
	public Order(Integer orderId, ReceivingAddress receivingAddress,
			Short state, Timestamp orderTime, Timestamp payTime,
			Timestamp confirmTime) {
		this.orderId = orderId;
		this.receivingAddress = receivingAddress;
		this.state = state;
		this.orderTime = orderTime;
		this.payTime = payTime;
		this.confirmTime = confirmTime;
	}

	/** full constructor */
	public Order(Integer orderId, ReceivingAddress receivingAddress,
			Short state, Timestamp orderTime, Timestamp payTime,
			Timestamp confirmTime, Set<OrderCommodityInfo> orderCommodityInfos) {
		this.orderId = orderId;
		this.receivingAddress = receivingAddress;
		this.state = state;
		this.orderTime = orderTime;
		this.payTime = payTime;
		this.confirmTime = confirmTime;
		this.orderCommodityInfos = orderCommodityInfos;
	}

	// Property accessors
	@Id
	@Column(name = "order_id", unique = true, nullable = false)
	public Integer getOrderId() {
		return this.orderId;
	}

	public void setOrderId(Integer orderId) {
		this.orderId = orderId;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "address_id", nullable = false)
	public ReceivingAddress getReceivingAddress() {
		return this.receivingAddress;
	}

	public void setReceivingAddress(ReceivingAddress receivingAddress) {
		this.receivingAddress = receivingAddress;
	}

	@Column(name = "state", nullable = false)
	public Short getState() {
		return this.state;
	}

	public void setState(Short state) {
		this.state = state;
	}

	@Column(name = "order_time", nullable = false, length = 19)
	public Timestamp getOrderTime() {
		return this.orderTime;
	}

	public void setOrderTime(Timestamp orderTime) {
		this.orderTime = orderTime;
	}

	@Column(name = "pay_time", nullable = false, length = 19)
	public Timestamp getPayTime() {
		return this.payTime;
	}

	public void setPayTime(Timestamp payTime) {
		this.payTime = payTime;
	}

	@Column(name = "confirm_time", nullable = false, length = 19)
	public Timestamp getConfirmTime() {
		return this.confirmTime;
	}

	public void setConfirmTime(Timestamp confirmTime) {
		this.confirmTime = confirmTime;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "order")
	public Set<OrderCommodityInfo> getOrderCommodityInfos() {
		return this.orderCommodityInfos;
	}

	public void setOrderCommodityInfos(
			Set<OrderCommodityInfo> orderCommodityInfos) {
		this.orderCommodityInfos = orderCommodityInfos;
	}

}